<template>
	<view class="bnav">
		<view class="app-same" v-bind:style="{ color:icolor[0]}" @click="itemClick(0)">
			<uni-icons type="home" v-bind:color="icolor[0]" size="40"></uni-icons>
			<text>书城</text>
		</view>
		<view class="app-same" v-bind:style="{ color:icolor[1]}" @click="itemClick(1)">
			<uni-icons type="bars" v-bind:color="icolor[1]" size="40"></uni-icons>
			<text>书架</text>
		</view>
		<view class="app-same" v-bind:style="{ color:icolor[2]}" @click="itemClick(2)">
			<uni-icons type="person" v-bind:color="icolor[2]" size="40"></uni-icons>
			<text>我</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				icolor: ['red', null, null],
			}
		},
		onLoad() {
			//初始化选择 home
			this.itemClick(0)
		},
		methods: {
			//子组件回调
			navCallback(i){
				this.$emit('navCallback',i)
			},
			itemClick(i) {
				this.setColor(i)
				this.navCallback(i)
			},
			setColor(i) {
				this.icolor = [null, null, null]
				if (i == 0) {
					this.icolor[0] = 'red'
				} else if (i == 1) {
					this.icolor[1] = 'red'
				} else if (i == 2) {
					this.icolor[2] = 'red'
				}
			}
		}
	}
</script>

<style>
	.bnav {
		display: flex;
		flex-wrap: nowrap;
		max-height: 85px;
	}

	.app-same {
		width: 33vw;
		height: 135rpx;
		text-align: center;
		display: flex;
		flex-direction: column;
	}

	.itme-this {
		color: #007AFF;
	}
</style>
